//
//  UIBarButtonItem+Extension.m
//  WisdomFamilyDoctor
//
//  Created by jinglian on 16/6/20.
//  Copyright © 2016年 kinglian. All rights reserved.
//

#import "UIBarButtonItem+Extension.h"
//#import "KLNavButton.h"

@implementation UIBarButtonItem (Extension)

/*
+ (instancetype )app_createBackNavigationBarWithTarget:(id)target action:(SEL)action {
    KLNavButton *backBtn = [KLNavButton navButton];
    
    [backBtn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
    
    return item;
}
 */

+ (instancetype )app_createItemTitle:(NSString *)title target:(id)target action:(SEL)action {
    return [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStylePlain target:target action:action];
}

+ (instancetype )app_createItemImageName:(NSString *)imageName target:(id)target action:(SEL)action {
    return [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:imageName] style:UIBarButtonItemStylePlain target:target action:action];
}

+ (instancetype)app_crateNavigationBarItemImageNamed:(NSString *)imageNamed highImageNamed:(NSString *)highImageNamed size:(CGSize)size target:(id)target action:(SEL)action {
    UIButton *itemButton = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [itemButton setImage:[UIImage imageNamed:imageNamed] forState:UIControlStateNormal];

    if (highImageNamed != nil) {
        [itemButton setImage:[UIImage imageNamed:highImageNamed] forState:UIControlStateHighlighted];
    }
    
    if (size.width != 0 && size.height != 0) {
        itemButton.frame = CGRectMake(0, 0, size.width, size.height);
    }
    
    [itemButton addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:itemButton];
    
    return item;
}



@end
